#include<iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;
		int d;
		cin >> d;
		bool flag = 0;
		if (d == 1) {
			if (abs(b - c) % 3 == 0) flag = 1;
		}
		else if (d == 2) {
			if (abs(a - c) % 3 == 0) flag = 1;
		}
		else {
			if (abs(a - b) % 3 == 0) flag = 1;
		}
		if (flag) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}